package com.gitee.wsl.mathematics.vector

import com.gitee.wsl.mathematics.vector.ext.distanceTo
import com.gitee.wsl.mathematics.vector.ext.squaredDistanceTo
import com.gitee.wsl.mathematics.vector.vec2.Vec2f
import com.gitee.wsl.mathematics.vector.vec3.Vec3f
import com.gitee.wsl.mathematics.vector.vec4.Vec4f
import kotlin.math.sqrt
import kotlin.test.Test
import kotlin.test.assertEquals

class DistanceTest {
    @Test
    fun vec2_distance() = assertEquals(sqrt(13f), Vec2f(2f, 3f).distanceTo(Vec2f(4f, 6f)))

    @Test
    fun vec3_distance() = assertEquals(sqrt(29f), Vec3f(2f, 3f, 4f).distanceTo(Vec3f(4f, 6f, 8f)))

    @Test
    fun vec4_distance() = assertEquals(
        sqrt(54f), Vec4f(2f, 3f, 4f, 5f).distanceTo(Vec4f(4f, 6f, 8f, 10f))
    )

    @Test
    fun vec2_sqrDistance() = assertEquals(
        13f, Vec2f(2f, 3f).squaredDistanceTo(Vec2f(4f, 6f))
    )

    @Test
    fun vec3_sqrDistance() = assertEquals(
        29f, Vec3f(2f, 3f, 4f).squaredDistanceTo(Vec3f(4f, 6f, 8f))
    )

    @Test
    fun vec4_sqrDistance() = assertEquals(
        54f, Vec4f(2f, 3f, 4f, 5f).squaredDistanceTo(Vec4f(4f, 6f, 8f, 10f))
    )
}